<?php

/**
 * Formulário de Usuário
 * @author Wanderson Henrique Camargo Rosa
 * @see    APPLICATION_PATH /forms/Usuario.php
 */
class Application_Form_Usuario extends Zend_Form
{
    public function init()
    {
        $this->setAttrib('accept-charset', 'utf-8');

        $idusuario = new Zend_Form_Element_Hidden('idusuario');
        $idusuario->loadDefaultDecorators();
        $idusuario->removeDecorator('Label')
            ->addFilter(new Zend_Filter_Int())
            ->addFilter(new Zend_Filter_Null());
        $this->addElement($idusuario);

        $display = new Zend_Form_Element_Text('display');
        $display->setLabel('Nome Completo')->setRequired(true)
            ->setAllowEmpty(true)->addFilter(new Zend_Filter_Null())
            ->addValidator(new Zend_Validate_StringLength(1,40))
            ->addValidator(new Zend_Validate_Alnum(true));
        $this->addElement($display);

        $nome = new Zend_Form_Element_Text('nome');
        $nome->setLabel('Usuário')->setRequired(true)->setAllowEmpty(false)
            ->addValidator(new Zend_Validate_NotEmpty())
            ->addValidator(new Zend_Validate_StringLength(1,20))
            ->addValidator(new Zend_Validate_Alpha(false))
            ->addFilter(new Zend_Filter_StringToLower());
        $this->addElement($nome);

        $senha = new Zend_Form_Element_Password('senha');
        $senha->setLabel('Senha')->setRequired(false)->setAllowEmpty(true)
            ->setRenderPassword(false);
        $this->addElement($senha);

        $ativado = new Zend_Form_Element_Checkbox('ativado');
        $ativado->setLabel('Ativado')->addFilter(new Zend_Filter_Boolean());
        $this->addElement($ativado);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Gravar')->setIgnore(true);
        $this->addElement($submit);

        $this->setName('usuario_form')->setMethod(self::METHOD_POST);
    }
}